const path = require('path')
const externals = {
  vue: 'Vue',
  'element-ui': 'ELEMENT',
  xlsx: 'XLSX',
  echarts: 'echarts',
  'highlight.js': 'hljs',
  'video.js': 'Video',
  'cos-js-sdk-v5': 'COS',
  'darkmode-js': 'Darkmode'
}
module.exports = {
  publicPath: './',
  lintOnSave: false,
  chainWebpack: config => {
    const svgRule = config.module.rule('svg')
    svgRule.uses.clear()
    svgRule
      .test(/.svg$/)
      .include.add(path.resolve(__dirname, './src/icons/svg'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
    const fileRule = config.module.rule('file')
    fileRule.uses.clear()
    fileRule
      .test(/.svg$/)
      .exclude.add(path.resolve(__dirname, './src/icons/svg'))
      .end()
      .use('file-loader')
      .loader('file-loader')
  },
  configureWebpack: {
    externals
  }
}
